package com.reebake.ideal.message.controller.client;

import cn.hutool.core.bean.BeanUtil;
import com.reebake.ideal.message.client.MessageVerifyCodeClient;
import com.reebake.ideal.message.entity.MessageVerifyCodeDTO;
import com.reebake.ideal.message.entity.MessageVerifyCodeEntity;
import com.reebake.ideal.message.service.MessageVerifyCodeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/client/message/verify-code")
public class MessageVerifyCodeClientController implements MessageVerifyCodeClient {

    @Autowired
    private MessageVerifyCodeService messageVerifyCodeService;

    @Override
    public void send(MessageVerifyCodeDTO verifyCodeDTO) {
        messageVerifyCodeService.sendVerifyCode(BeanUtil.copyProperties(verifyCodeDTO, MessageVerifyCodeEntity.class));
    }

    @Override
    public Boolean verify(MessageVerifyCodeDTO verifyCodeDTO) {
        return messageVerifyCodeService.verify(BeanUtil.copyProperties(verifyCodeDTO, MessageVerifyCodeEntity.class));
    }
}
